package com.yidu.manage.controller.base;

import com.yidu.manage.domain.SysRole;
import com.yidu.manage.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("system/user")
public class SysUserController
{
    @Autowired
    private ISysRoleService sysRoleService;

    /**
     * 根据用户编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermit('system:user:query')")
    @GetMapping(value = {"/", "/{userId}"})
    public Object getInfo(@PathVariable(value = "userId", required = false) Long userId)
    {
        List<SysRole> roles = sysRoleService.selectRoleAll();
//        ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
//        ajax.put("posts", postService.selectPostAll());
//        if (StringUtils.isNotNull(userId))
//        {
//            ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
//            ajax.put("postIds", postService.selectPostListByUserId(userId));
//            ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
//        }
//        return ajax;
        return null;
    }
}
